package org.example.cicdi.service.impl.org;


import org.example.cicdi.enums.EnumWhiteColumnAnnotation;
import org.example.codegenerate.modelext.WebVo.annotation.Column.PageVo;
import org.example.codegenerate.modelext.WebVo.domian.column.ColumnVoDomain;

import org.springframework.stereotype.Service;

import java.lang.reflect.Field;

@Service
public class PageVoAnnotatonImpleService implements FieldAnnotationService{

	@Override
	public String getCode() {
		return EnumWhiteColumnAnnotation.PageVo.getCode();
	}

	@Override
	public ColumnVoDomain handleFieldVo(Field field, ColumnVoDomain column) {
		PageVo vo = field.getAnnotation(PageVo.class);
		if (vo != null) {
			org.example.codegenerate.modelext.WebVo.domian.column.PageVo page =  column.getPageVo();
			if (page == null) {
				page = new org.example.codegenerate.modelext.WebVo.domian.column.PageVo();
				column.setPageVo(page);
			}
			
			page.setFieldDefaultValue(vo.fieldDefaultValue());
			page.setFieldLength(vo.fieldLength());
			page.setFieldShowType(vo.fieldShowType().getType());
			page.setIsQuery(vo.isQuery());
			page.setIsReadOnly(vo.isReadOnly());
			page.setIsShowForm(vo.isShowForm());
			page.setIsShowList(vo.isShowList());
			page.setOrderNum(vo.orderNum());
			page.setQueryMode(vo.queryMode());
			page.setSortFlag(vo.sortFlag());
		}
		
		return column;
	}
}
